﻿using BW.MesProject.Public.ErrorCode;
using BW.MesProject.WareHouse.Domain;
using BW.MesProject.WareHouse.Infrastructure.Dto.Input;
using BW.MesProject.WareHouse.Infrastructure.Dto.OutPut;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BW.MesProject.WareHouse.Infrastructure
{
    /// <summary>
    /// 审批流程
    /// </summary>
    public interface IProcessNodeServices
    {
        /// <summary>
        /// 添加审批流程节点主表,审批流程节点明细
        /// </summary>
        /// <param name="processNodeInput">审批流程节点信息</param>
        /// <returns>添加结果</returns>
        ApiResult<int> AddProcessNodes(ProcessNodeInput processNodeInput);
        
        /// <summary>
        /// 添加审批表\审批流程记录表
        /// </summary>
        /// <param name="approvalProcess">审批流程</param>
        /// <returns>操作结果</returns>
        ApiResult<bool> AddApproveProcess(ApprovalProcess approvalProcess);

        #region 查询
        /// <summary>
        /// 获取审批流程节点列表（分页）
        /// </summary>
        /// <param name="qryInput">查询参数</param>
        /// <param name="PNType">流程节点类型（可为空）</param>
        /// <returns>审批流程节点列表</returns>
        ApiResult<List<ProcessNodesOut>> GetProcessNodesList(QryInput qryInput, string PNType = null);
        
        /// <summary>
        /// 获取指定流程节点的明细列表
        /// </summary>
        /// <param name="processNodesId">流程节点ID</param>
        /// <returns>流程节点明细列表</returns>
        ApiResult<List<ProcessNodesItem>> GetProcessNodesItemsByNodeId(string processNodesId);

        /// <summary>
        /// 获取单个流程节点明细
        /// </summary>
        /// <param name="NodeSn">节点序列号</param>
        /// <returns>流程节点明细信息</returns>
        ApiResult<ProcessNodesItem> GetProcessNodesItemById(string NodeSn);
        
        /// <summary>
        /// 获取审批流程列表（分页）
        /// </summary>
        /// <param name="qryInput">查询参数</param>
        /// <param name="UserID">用户ID</param>
        /// <returns>审批流程列表</returns>
        ApiResult<List<ApprovalProcess>> GetApprovalProcessList(QryInput qryInput, string UserID);
        
        /// <summary>
        /// 获取审批流程列表（根据申请单ID）
        /// </summary>
        /// <param name="RequisitionId">申请单ID</param>
        /// <returns>审批流程列表</returns>
        ApiResult<List<ApprovalProcess>> GetApprovalProcessByRId(string RequisitionId);
        
        /// <summary>
        /// 获取审批流程的所有审批记录
        /// </summary>
        /// <param name="qryInput">查询参数</param>
        /// <param name="ApprovalProcessId">审批流程ID</param>
        /// <returns>审批记录列表</returns>
        ApiResult<List<ProcessRecords>> GetProcessRecordsByProcessId(QryInput qryInput, string ApprovalProcessId);
        #endregion

        #region 修改
        /// <summary>
        /// 修改审批流程节点主表及明细信息
        /// </summary>
        /// <param name="processNodeInput">流程节点信息</param>
        /// <returns>操作结果</returns>
        ApiResult<bool> UpdateProcessNodes(ProcessNodeInput processNodeInput);
        
        /// <summary>
        /// 停用审批流程节点主表
        /// </summary>
        /// <param name="processNodes">流程节点信息</param>
        /// <returns>操作结果</returns>
        ApiResult<bool> UpdateProcessNodesEnable(ProcessNodes processNodes);
        
        /// <summary>
        /// 取消审批流程
        /// </summary>
        /// <param name="approvalProcessId">审批流程ID</param>
        /// <param name="cancelReason">取消原因</param>
        /// <param name="operatorId">操作人ID</param>
        /// <returns>操作结果</returns>
        ApiResult<bool> CancelApprovalProcess(string approvalProcessId, string cancelReason, string operatorId);
        #endregion

        #region 删除
        /// <summary>
        /// 删除审批流程节点（包含相关的明细记录）
        /// </summary>
        /// <param name="processNodesId">流程节点ID</param>
        /// <returns>操作结果</returns>
        ApiResult<bool> DeleteProcessNode(string processNodesId);
        #endregion

        #region 审批操作
        /// <summary>
        /// 同意审批流程
        /// </summary>
        /// <param name="approval">审批流程信息</param>
        /// <returns>操作结果</returns>
        ApiResult<bool> ApproveProcess(ApprovalProcess approval);
        
        /// <summary>
        /// 拒绝审批流程
        /// </summary>
        /// <param name="approval">审批流程信息</param>
        /// <returns>操作结果</returns>
        ApiResult<bool> RejectProcess(ApprovalProcess approval);
        #endregion
    }
}
